<template>
  <div>
    <div class="content">
      <el-form
        :model="dataForm"
        ref="dataForm"
        @keyup.enter.native="dataFormSubmit()"
        label-width="100px"
      >
        <el-form-item label="笔记查重" prop="noteStandard">
          <div style="display: flex;">
            <el-input v-model="dataForm.noteStandard" :disabled="disabled" style="width: 100px;margin-right: 10px;"></el-input>
            <div>%</div>
          </div>
        </el-form-item>
        <el-form-item label="书籍章节查重" prop="chapterStandard">
          <div style="display: flex;">
            <el-input v-model="dataForm.chapterStandard" :disabled="disabled" style="width: 100px;margin-right: 10px;"></el-input>
            <div>%</div>
          </div>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" @click="editForm"  v-if="disabled">修改</el-button>
          <el-button type="primary" @click="dataFormSubmit" v-if="!disabled">确定</el-button>
          <el-button v-if="!disabled" @click="cancel">取消</el-button>
        </el-form-item>
      </el-form>
    </div>
  </div>
</template>

<script>
  export default {
    data() {
      return {
        rember: "",
        messageShow: false,
        dataForm: {
          noteStandard:'',
          chapterStandard: ''
        },
        disabled: true,
        eggtrue:true,
        customInfo:false,
        bookId:'',
      };
    },
    mounted(){
      this.getEggs();
    },
    methods: {
      getEggs(){
        this.disabled = true;
        this.$http({
          url: this.$http.adornUrl(`/course/noterecord/similarity/standard`),
          method: 'get',
          params: this.$http.adornParams()
        }).then(({data}) => {
          if (data && data.code === 0) {
            this.dataForm.noteStandard = JSON.parse(data.msg).noteStandard
            this.dataForm.chapterStandard = JSON.parse(data.msg).chapterStandard
          }
        })
      },
      //修改
      editForm() {
        this.disabled = false;
      },
      //提交
      dataFormSubmit() {
        this.$http({
          url: this.$http.adornUrl(`/course/noterecord/similarity/standard/update`),
          method: 'post',
          data: this.$http.adornData(this.dataForm)
        }).then(({data}) => {
          if(data.code === 0) {
            this.$message.success('操作成功')
            this.disabled = true
            this.getEggs()
          }
        })
      },
      //取消
      cancel(){
        this.disabled = true;
      }
    }
  };
</script>
<style scoped>
  .content {
    width: 50%;
    height: 350px;
    margin: 0 auto;
    border: solid 1px #ccc;
  }
  .el-form {
    width: 80%;
    margin: 0 auto;
    padding-top: 20px;
  }
  .el-row {
    display: flex;
    align-items: center;
    height: 45px;
    font-size: 16px;
  }
</style>
